<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
	<head>
		<base href="<%=basePath %>" />
		<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<title></title>
		<link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="css/global.css" media="all" />
		
	</head>
	<body>
		<div class="admin-main">

			<blockquote class="layui-elem-quote">
				<!-- <a href="user/exportexcel" class="layui-btn layui-btn">
					<i class="fa fa-shopping-cart" aria-hidden="true"></i> 导出信息
				</a> -->
				<a href="javascript:;" class="layui-btn layui-btn" id="getSelected">
					<i class="fa fa-shopping-cart" aria-hidden="true"></i> 审批
				</a>
				<div class="layui-inline">
					<div class="layui-input-inline">
						<input type="text" id="sh-xm" placeholder="姓名.." autocomplete="off" class="layui-input" >
					</div>
				</div>
				<a href="javascript:;" class="layui-btn layui-btn" id="search">
					<i class="layui-icon">&#xe615;</i> 搜索
				</a>
			</blockquote>
			<fieldset class="layui-elem-field">
				<legend>员工信息修改申请表</legend>
				<div class="layui-field-box layui-form">
					<table class="layui-table admin-table">
						<thead>
							<tr>
								<th style="width: 30px;"><input type="checkbox" lay-filter="allselector" lay-skin="primary"></th>
								<th>员工编码</th>
								<th>姓名</th>
								<th>性别</th>
								<th>名族</th>
								<th>籍贯</th>
								<th>年龄</th>
								
								<th>身份证号</th>
								<th>学历</th>
								<th>学位</th>
								<th>职称</th>
								
								<th>政治面貌</th>
								<th>婚姻状况</th>
								<th>入职日期</th>
								<th>所属项目</th>
								<th>所在部门</th>
								<th>岗位名称</th>
								<th>岗位类型</th>
								<th>用工性质</th>
								<th>联系电话</th>
								<th>照片</th>
							</tr>
						</thead>
						<tbody id="content">
						</tbody>
						<tfoot >
							<tr>
								<th colspan="17">
									<div class="admin-table-page">
										<div id="paged" class="page">
										</div>
									</div>
								</th>
							</tr>
						</tfoot>
					</table>
				</div>
			</fieldset>
		
		</div>
		<!--模板-->
		<script type="text/html" id="tpl">
			{{# layui.each(d.list.list, function(index, item){ }}
			<tr>
				<td><input type="checkbox" lay-skin="primary"></td>
				<td>{{ item.ygbm }}</td>
				<td>{{ item.xm }}</td>
				<td>{{ item.xb }}</td>
				<td>{{ item.mz }}</td>
				<td>{{ item.jg }}</td>
 				<td>{{ item.gage }}</td>

				<td>{{ item.sfzh }}</td>
				<td>{{ item.xl }}</td>
				<td>{{ item.xw }}</td>
 				<td>{{ item.zc }}</td>

				<td>{{ item.zzmm }}</td>
				<td>{{ item.hyzk }}</td>
				<td>{{ item.rzrq }}</td>
				<td>{{ item.xmmc }}</td>
				<td>{{ item.szbm }}</td>
				<td>{{ item.gwmc }}</td>
				<td>{{ item.gwlx }}</td>
				<td>{{ item.ygxz }}</td>
				<td>{{ item.lxdh }}</td>
				<td><img style="width: 2.5em;" src='{{ item.zp }}'/><a href="javascript:;" data-name='{{ JSON.stringify(item) }}' data-opt="edit" class="layui-hide"></a></td>
				
			</tr>
			{{# }); }}
		</script>
		<script type="text/javascript" src="plugins/layui/layui.js"></script>
		<script>
			layui.config({
				base: 'js/'
			});
			//全局的AJAX访问，处理AJAX清求时SESSION超时
			
          
			layui.use(['paging', 'form', 'laydate', 'upload','layer'], function() {
				var $ = layui.jquery,
					paging = layui.paging(),
					layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
					layer = layui.layer, //获取当前窗口的layer对象
					form = layui.form();
				$.ajaxSetup({
				    contentType:"application/x-www-form-urlencoded;charset=utf-8",
				    complete:function(XMLHttpRequest,textStatus){
				          //通过XMLHttpRequest取得响应头，sessionstatus           
				          var sessionstatus=XMLHttpRequest.getResponseHeader("sessionstatus"); 
				          loginUrl = XMLHttpRequest.getResponseHeader("location"); 
				          if(sessionstatus=='00004'){
				               //这里怎么处理在你，这里跳转的登录页面
				        	 // if( window.top != window.self ){
				  				window.top.location = loginUrl;
				  			//}
				       }
				    }
				});
		          var doajax = function(type, url,_data){  
		              $.ajax({
						type: type,
						url:  url,
						data: _data,
						dataType: 'json',
						success: function(result, status, xhr) {
							if(result.flag){
							 loadtab(data);
							 layer.msg(result.msg);
								}
							}
					});
		          }
			var data = {};
			var loadtab = function(data){ 
					paging.init({
					url: 'user/finduserchanges', //地址
					elem: '#content', //内容容器
					params: data,
					type: 'POST',
					tempElem: '#tpl', //模块容器
					pageConfig: { //分页参数配置
						elem: '#paged', //分页容器
						pageSize: 10 //分页大小
					},
					success: function() { //渲染成功的回调
						//alert('渲染成功');
					},
					fail: function(msg) { //获取数据失败的回调
						//alert('获取数据失败')
					},
					complate: function() { //完成的回调
						//alert('处理完成');
						//重新渲染复选框
						form.render('checkbox');
						form.on('checkbox(allselector)', function(data) {
							var elem = data.elem;

							$('#content').children('tr').each(function() {
								var $that = $(this);
								//全选或反选
								$that.children('td').eq(0).children('input[type=checkbox]')[0].checked = elem.checked;
								form.render('checkbox');
							});
						});
					}
				});
			}
			loadtab(data);
				//获取所有选择的列
				$('#getSelected').on('click', function() {
					var names = '';
					$('#content').children('tr').each(function() {
						var $that = $(this);
						var $cbx = $that.children('td').eq(0).children('input[type=checkbox]')[0].checked;
						if($cbx) {
							var n = $that.children('td:last-child').children('a[data-opt=edit]').data('name').changeid;
							names += n + ',';
							if(!names) layer.msg("请至少选择一项");
						}
					});
					//userchangeapprove
			         $.ajax({
							type: 'post',
							url:  'user/userchangeapprove',
							data: {ids: names},
							dataType: 'json',
							success: function(result, status, xhr) {
								if(result.flag){
								 loadtab(data);
								 layer.msg(result.msg);
									}
								}
						});
				});

				$('#search').on('click', function() {
					//parent.layer.alert('你点击了搜索按钮');
					data = {xm: $('#sh-xm').val()};
					loadtab(data);
					
				});
			});
		</script>
	</body>
	</body>

</html>